<style lang="less">
  .pay-way-config-add{

  }
</style>

<template>
  <el-dialog title="新增付款方式" :visible.sync="dialogVisible" size="tiny" class="pay-way-config-add">
    <el-form label-width="120px" ref="form" :model="form">
      <el-form-item label="付款方式名称"
                    :rules="{ required: true, message: '请输入付款方式名称', trigger: 'blur' }"
                    prop="payWayName">
        <el-input v-model="form.payWayName"></el-input>
      </el-form-item>
      <el-form-item label="付款方式编号"
                    :rules="{ type:'number', required: true, message: '请输入付款方式编号', trigger: 'blur' }"
                    prop="payWay">
        <el-input v-model.number="form.payWay"></el-input>
      </el-form-item>
      <el-form-item label="序号"
                    :rules="{ type:'number', required: true, message: '请输入序号', trigger: 'blur' }"
                    prop="sort">
        <el-input v-model.number="form.sort"></el-input>
      </el-form-item>
      <el-form-item label="费率"
                    :rules="{ type:'number',message: '请输入费率', trigger: 'blur' }"
                    prop="sort">
        <el-input v-model.number="form.rate"></el-input>
      </el-form-item>
      <el-form-item label="说明">
        <el-input type="textarea" v-model="form.description"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="createform" :loading="loading">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'PayWayConfigAdd',
  componentName: 'PayWayConfigAdd',
  data () {
    return {
      dialogVisible: false,
      loading: false,
      form: {
        id: null,
        payWayName: null,
        payWay: null,
        sort: null,
        rate: null,
        type: null,
        isShow: null,
        isEnable: null,
        description: null
      }
    };
  },
  methods: {
    reset: function () {
      if (this.$refs.form) {
        this.$refs.form.resetFields();
      }
      this.$ue.resetObjNull(this.form);
    },
    show (o) {
      this.reset();
      if (o) {
        this.form.id = o.id;
        this.form.payWayName = o.payWayName;
        this.form.payWay = o.payWay;
        this.form.sort = o.sort;
        this.form.rate = o.rate;
        this.form.description = o.description;
        this.form.type = o.type;
        this.form.isShow = o.isShow;
        this.form.isEnable = o.isEnable;
      } else {
        this.form.type = 'CLOSE';
        this.form.isShow = false;
        this.form.isEnable = false;
      }
      this.dialogVisible = true;
      this.loading = false;
    },
    hide () {
      this.loading = false;
      this.dialogVisible = false;
    },
    loadingFalse () {
      this.loading = false;
    },
    createform () {
      this.$refs.form.validate((valid) => {
        if (valid) {
          let o = Object.assign({}, this.form);
          this.$emit('comfirmSuccess', o);
        }
      });
    }
  },
  mounted () {
  }
};
</script>
